package com.asking.controller;

import com.asking.domain.User;
import com.asking.service.LoginService;
import com.asking.vo.Result;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Resource
    private LoginService loginService;

    @PostMapping()
    public ResponseEntity<Result> login(User user){
        try {
            Result result =   loginService.login(user);
                return new ResponseEntity<>(result,HttpStatus.OK);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseEntity<>(new Result(500,"服务器异常"),HttpStatus.OK);
        }

    }
}
